How to have a % in a python statement without using two % [closed] - python

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
so my python application opens a link that would be found in my config file. I would like to make it so it would like to allow it to go to the website without doubling the %. Heres what I would want config.get('CONFIG', 'Website') the web address has a bunch of %'s in the link but when I run it, the process ends

I'm assuming you are using the configparser module?
If so, you can use ConfigParser(interpolation=None) to disable string interpolation (which controls the behavior of % characters in the config file).
(Or on older versions of Python, you may need to use RawConfigParser instead.)

Related

Which of the following regular expressions can be used to get the domain name? python [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Which of the following regular expressions can be used to get the domain name?
I try the next code but it doesn't work, there is something that i'm doing wrong?
In the picture the another options
txt = 'I refer to https://google.com and i never refer http://www.baidu.com'
print(txt.findall(?<=https:\/\/)([A-Za-z0-9.]*))
You selected the correct regexp, you just have to quote it to use it in Python. You also need to call re.findall(), it's not a string method.
import re
txt = 'I refer to https://google.com and i never refer http://www.baidu.com'
print(re.findall(r'(?<=https:\/\/)([A-Za-z0-9.]*)', txt))
Here's a regex that'll get your URLs
http(s?)://(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]
It'll work for https://stackoverflow.com, http://example.com, https://example.com etc...
If you don't want the http or https just use this:
(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]

Start script from different file directory using QProcess.start() [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have tried looking this up, but for some reason I cannot find anything about it. How do I run a script by giving the particular file directory in start()?
This works (when Test is in the same folder as the main script):
self.process.start("python3 Test.py")
This does NOT work:
self.process.start("python3 /my/path/Test.py")
Try this:
self.process.start("python3 ../my/path/Test.py") # added two periods before "/m"

Python: Scraping special Characters Writing to CSV [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Hello I am trying to scrape a website and its going fine, till the point I try to save the data into a csv via csv module writer. I traced back to the data and find out that 7 años is the string which isn't allowing the data to store properly.
I READ A LOT ON THIS TOPIC BEFORE POSTING... BUT COULDN'T GRASP THE CONCEPT.
Python is throwing some encoding error which got me to reading and I found that csv module isn't capable of unicode.
Is there any suggestion?
Try to use following solution
def sanitize_string(string):
return string.replace('\t', '')
Try to encode the string using encode function
your_variable = sanitize_string("your string")
your_variable.encode('utf8')
Hope this will help you.

how to disable WORD WRAP in python IDLE [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I’m trying to print a string that is too long to be displayed on one line, so it automatically wraps to the next line. The problem is that I need it to all stay on one line and just go off the screen (where I can just scroll left to right to see it all).Is there a way to to disable word wrap in python IDLE
by changing somethings in configure option
Text wrapping is a function of your terminal, not python. All that python does is send a string to the terminal - think about it, when you say print "abcdef\n", there's no character in there that tells the terminal to wrap-text!
You just need to configure the environment you're coding in. There should be a pretty easily accessible 'settings' option. However, if you can't find it, then tell us what environment you're using - we might be able to help.

Python / package source code [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
When I ctrl click a builtin function in my IDE I noticed I usually get sended to an init file which holds the function but it just returns the function again.. It states a vague doc string like 'original footprint unknown'
Where do I find the real functions ?
For example where is print_function
the specific example, print is defined in C, in the bltinmodule.c: specifically.
http://hg.python.org/cpython/file/3.3/Python/bltinmodule.c#l1518
More generally, functions implemented in C have no equivalent to the source file you would read in python; the C code is compiled into binary machine code, and no reference to where that bit of code might have come from is (usually) retained in the result; and even if there was, it's unlikely that you happen to have the source code installed in a place your IDE is likely to find it, unless you built it yourself, with debug symbols, and are running the C executable process in that ide's debugger.
Usually in the same directory where that file is. (Which I can't possibly know.)

Categories

Resources