Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
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
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I found this code on github: https://github.com/Abrand88/Reddit-Tor-proxy-voting-bot/blob/master/reddit_proxy_voting_bot.py
I know that its a bot and potentially malicious but I thinks its cool nonetheless. From an educational perspective how do I get it working?: When I run the program it outputs "socket:" twice and then gives the error "KeyError: '127.0.0.1'"
Any thoughts?
it's using a dictionary and can't find the key for your local host.
this is probably causing the error breaking:
ip_hash={}; # the dictionary is made
and
ip_hash[ip] = 1; # the dictionary is incorrectly accessed
this part alone isn't a good idea:
if ip in ip_hash:
print " repeat " + ip;
else:
ip_hash[ip] = 1;
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
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
Improve this question
I have a cvs file containing the following format of numbers 4,16221E+13 I don't really know what it means.
How can I replace them? is there a special function or script to do it?
Thank you,
Hani.
It means 4.16221 x 10^13, i.e. 41622100000000.
You can use:
float('4,16221E+13'.replace(',', '.'))
>>> 41622100000000.0
Python needs . as decimal point.
If you take the text, replace the , with an . then you can get the number it's likely supposed to be, eg:
>>> f = '4,16221E+13'
>>> float(f.replace(',', '.'))
41622100000000.0
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 have a string in python, which is a URL:
http://weibo.com\/p\/aa\/weibo?from=bb&wvr=5.1&mod=weibomore#cc
I want to a real URL that I can paste it in my chrome:
http://weibo.com/p/aa/weibo?from=bb&wvr=5.1&mod=weibomore#cc
Please tell me how to chang it IN PYTHON~~~
It appears that you simply need to remove the backward slashes from your original string.
You can do that using replace as such..
url = string.replace("\\", "")
<your url string>.replace("\\","") will do the trick, but as has been pointed out, it would be better to fix the source of this.
The solution will also remove any backquotes ("\"). Even legitimate ones - so it's not a general solution. Backslashes are allowed in urls*, though its very unusual and causes problems
*Then again perhaps not: http://www.ietf.org/rfc/rfc2396.txt - it looks like this is a confusing question.
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 have the following sentence:
Graft Concepts has partnered with\u00a0several sites\u00a0to offer customization options for backplates, so customers will be able to design their own with\u00a0
I'd like to get rid of all instances of "\u00a0", whether or not they are connected to other words, e.g. "with\u00a0several"
How would I do this using regex with python? I've tried experimenting with re.compile() and re.findall(), but I couldn't get this working?
Thanks.
You can just use .replace:
s = s.replace('\\u00a0', ' ')
This works under Python 2:
import re
st='''Graft Concepts has partnered with\u00a0several sites\u00a0to offer customization options for backplates, so customers will be able to design their own with\u00a0'''
st=re.sub(ur'\\u00a0','',st,re.UNICODE)
And this under Python 3:
st=re.sub(u'\\u00a0','',st,re.UNICODE)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
Psycopg is the most popular PostgreSQL adapter for the Python programming language.
The name Psycopg does not make sense to me.
I understand the last pg means Postgres, but what about Psyco?
I've always thought of it as psycho-Postgres.
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 3 years ago.
Improve this question
This is the package which has a webapp demo in it.
However, when I login use this demo, I get an error.
How to make this demo running on the gae-launcher?
Looks like a bug in gaema.
The line that's failing is trying to urlencode a dictionary of arguments that get passed to the OpenID endpoint. One or more of the values, perhaps your first or last name, has non-ASCII characters.
You might be able to work around it by replacing instances of this:
urllib.urlencode(args)
With this:
urllib.urlencode(dict([(k, args[k].encode('utf-8')) for k in args]))
For a more permanent fix, I would report the issue here:
http://code.google.com/p/gaema/issues/list