python-3.2

Python3 and pandas

我与影子孤独终老i 提交于 2019-12-18 13:13:28
问题 I have checked some other SO answers and googled somewhat extensively and cannot seem to find someone who has asked/answered this: I am running Ubuntu 12.04. I have python2.7 and python3.2 installed. (I ran sudo apt-get install python-numpy, python3-numpy, and similar with scipy). I ran sudo apt-get install python-pandas. It works perfectly fine with python2.7. It does not import in python3.2 I then modified my $PYTHONPATH to have the directory where pandas was installed, full aware that this

python 3.2 - find second smallest number in a list using recursion

痞子三分冷 提交于 2019-12-18 09:53:02
问题 So I need to find the second smallest number within a list of integers using recursion but I cannot for the life of me devise a way to do it. I can do it with to find smallest number using this: def smallest(int_list): if(len(int_list) == 1): return int_list[0] else: a = smallest(int_list[1:]) b = int_list[0] if(a <= b): return a else: return b Can anyone point me in the right direction? 回答1: Here is a short implementation that doesn't use min() or sorted() . It also works when there are

Sending mail error with python smtplib

懵懂的女人 提交于 2019-12-17 06:51:27
问题 I am attempting to use the python 3.2 SMTPlib.sendmail() function to send a message, after some modifcation of the SMTP library (namely commenting out the rset() function which was suppressing the error msg) I managed to retrieve the following error message from the server: SendMail Failed (554, b'Transaction failed : Cannot send message due to possible abuse; please visit http://postmaster.yahoo.com/abuse_smtp.html for more information') The yahoo mail SMTP server thinks I'm sending spam,

How to know/change current directory in Python shell?

自古美人都是妖i 提交于 2019-12-17 06:20:57
问题 I am using Python 3.2 on Windows 7. When I open the Python shell, how can I know what the current directory is and how can I change it to another directory where my modules are? 回答1: You can use the os module. >>> import os >>> os.getcwd() '/home/user' >>> os.chdir("/tmp/") >>> os.getcwd() '/tmp' But if it's about finding other modules: You can set an environment variable called PYTHONPATH , under Linux would be like export PYTHONPATH=/path/to/my/library:$PYTHONPATH Then, the interpreter

How to extract URL from HTML anchor element using Python3? [closed]

余生颓废 提交于 2019-12-13 22:50:55
问题 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 5 years ago . I want to extract URL from web page HTML source. Example: xyz.com source code: <a rel="nofollow" href="example/hello/get/9f676bac2bb3.zip">Download XYZ</a> I want to extract: example/hello/get/9f676bac2bb3.zip How to extract this URL? I don't understand regex. Also I don't know how to install

In Python what type of object does *zip(list1, list2) return? [duplicate]

余生颓废 提交于 2019-12-13 17:59:49
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Python: Once and for all. What does the Star operator mean in Python? x = [1, 2, 3] y = [4, 5, 6] zipped = zip(x, y) list(zipped) x2, y2 = zip(*zip(x, y)) x == list(x2) and y == list(y2) What type of object does *zip(x, y) return? Why res = *zip(x, y) print(res) doesn't work? 回答1: The asterisk "operator" in Python does not return an object; it's a syntactic construction meaning "call the function with the list

Python 3.2 Replace all words in a text document that are a certain length?

雨燕双飞 提交于 2019-12-13 07:57:33
问题 I need to replace all words in a text document that are of length 4 with a different word. For example, if a text document contained the phrase "I like to eat very hot soup" the words "like", "very", and "soup" would be replaced with "something" Then, instead of overwriting the original text document, it needs to create a new one with the changed phrase. Here is what I have so far: def replacement(): o = open("file.txt","a") #file.txt will be the file containing the changed phrase for line in

Pygame .Rect won't “collide” with mouse

杀马特。学长 韩版系。学妹 提交于 2019-12-13 04:31:17
问题 I am working on a simple game and with small circle "systems". I would like to be able to click each system so that I can do more with it later in game but I am having difficulty recognizing only a single click. I pass the randomly generated coords to a dictionary and then the collision for each rect should be checked with the mouse position but for some reason that is not working anymore. Any help is appreciated. Here is some of the more relevent code. for i in range(NumSystems): SysSize =

Change appearance of turtle

淺唱寂寞╮ 提交于 2019-12-12 19:43:14
问题 I am programming in python 3.2.2 turtle. I am able to make the turtle follow my cursor when I clack but now I have trouble changing the appearance of the turtle. In my code you will see a tank, and I want the image of the tank to be my turtle. Here is my code: #importing modules from turtle import Turtle from turtle import * #Setting up variables unVar1 = 25 unVar2 = 100 unVar3 = 90 unVar4 = 150 unVar5 = -30 unVar6 = 75 unVar7 = 50 screen = Screen() # create the screen #first part in making

Moving turtle according to the arrow keys

纵饮孤独 提交于 2019-12-12 19:36:42
问题 I am trying to make my turtle move according to the arrow keys on my keyboard. Does anybody know how to make a turtle in python 3.2.2 move according to the command of my arrow keys? By the way, my turtle is in the form of a tank if that affects anything. Here is my code: import turtle unVar1 = 25 unVar2 = 100 unVar3 = 90 unVar4 = 150 unVar5 = -30 unVar6 = 75 unVar7 = 50 def polySquare(t, x, y, length): t.goto(x, y) t.setheading(270) t.begin_poly() for count in range(4): t.forward(length) t