python-3.3

How to use 2to3 properly for python?

我怕爱的太早我们不能终老 提交于 2019-12-17 17:47:15
问题 I have some code in python 2.7 and I want to convert it all into python 3.3 code. I know 2to3 can be used but I am not sure exactly how to use it. Thanks for any help 回答1: As it is written on 2to3 docs, to translate an entire project from one directory tree to another, use: $ 2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode 回答2: If you don't have 2to3 on your path, you can directly invoke lib2to3 : python -m lib2to3 directory\file.py And as the docs (and other answers)

Heroku push rejected due to pip/distribute bug. What's the workaround?

那年仲夏 提交于 2019-12-14 00:33:46
问题 My local git/virtualenv is using pip version 1.3.1. When I try to push my Python 3.3.2 app to Heroku, I get Downloading/unpacking distribute==0.6.34 (from -r requirements.txt (line 5)) Running setup.py egg_info for package distribute Traceback (most recent call last): File "<string>", line 3, in <module> File "./setuptools/__init__.py", line 2, in <module> from setuptools.extension import Extension, Library File "./setuptools/extension.py", line 5, in <module> from setuptools.dist import _get

Can't start designed pyQt application

送分小仙女□ 提交于 2019-12-13 16:38:49
问题 I have just designed my application inside pyQt Designer 5, generated my main.ui to main.py and my assets.qrc to assets_rc.py. No errors, when I now run main.py from my terminal nothing happends. Have I missed a step? Am I supposed to edit my main.py file now? Cheers! Python 3.3.0 pyQT 5 回答1: This is for PyQt4 , but should be the same for PyQt5 . Let's say your ui is called "mainwindow.ui". Compile this with pyuic4 into "mainWindowUi.py" (or whatever, just stick to the name). Now create a

Total/Average/Changing Salary 1,2,3,4 Menu

余生长醉 提交于 2019-12-13 10:13:33
问题 Change your program so there is a main menu for the manager to select from with four options: Print the total weekly salaries bill. Print the average salary. Change a player’s salary. Quit When I run the program, I enter the number 1 and the program stops. How do I link it to the 4 below programs? Program: Chelsea_Salaries_2014 = {'Jose Mourinho':[53, 163500, 'Unknown']} Chelsea_Salaries_2014['Eden Hazard']=[22, 185000, 'June 2017'] Chelsea_Salaries_2014['Fernando Torres']=[29, 175000, 'June

what does 'int' object is not subscriptable mean? [closed]

夙愿已清 提交于 2019-12-13 09:57:29
问题 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 4 years ago . After some research I still do not know what 'int' object is not subscriptable means, all help will be appreciated. 回答1: It means you can't do i[1] if i is an integer. 来源: https://stackoverflow.com/questions/33647685/what-does-int-object-is-not-subscriptable-mean

TypeError: list of indices must be integers, not str

a 夏天 提交于 2019-12-13 08:30:44
问题 What is wrong in my code to give me the error: TypeError: List of indices must be integers, not str Here is my code: print("This programe will keep track of your TV schedule.") Finish = False Show = [] ShowStart = [] ShowEnd = [] while not Finish: print() ShowName = input("What is the shows name?: ") if ShowName == "": Finish = True else: ShowStartTime = input("What time does the show start?: ") ShowEndTime = input("What time does the show end?: ") Show.append(ShowName) ShowStart.append

importing numpy works with interpreter but not fully with pyscripter in python

谁说我不能喝 提交于 2019-12-13 06:59:27
问题 I'm working with python 3.3 (x64), and pyscripter 2.5.3 (x64), numpy 1.7 for python 3.3 (x64). When I import numpy in a script, I don't have all the functions of numpy available, only few of them (not a lot, and not array )? As if it doesn't manage to import all the file from numpy If I use IDLE it works fine, same with notepad++. 回答1: Depends on which Python engine you are using in pyscripter. The IDE offers a connect to its own internal installation of python and a remote installation

Python 3.3: separation argument (sep) giving an error

↘锁芯ラ 提交于 2019-12-13 04:21:52
问题 I am very new to programming and I'm starting out with Python. I tried to look up my question here but didn't really find anything. I'm trying to work a very simple print command but I'm getting an error for some reason that I don't understand. last = 'smith' middle = 'paul' first = 'john' print(first.capitalize(), middle.capitalize(), last.capitalize(), sep='\t') According to the answer in the book, this should be right, but every time I try to run it, I get an error with the 'sep': print

Crawler only loads one title

*爱你&永不变心* 提交于 2019-12-13 03:37:13
问题 i did some questions in here and them one guy gave me this code. But I need help because it is only bringing one result of my websites.txt Crawler.py import urllib.request import re regex = "<title>(.+?)</title>" pattern = re.compile(regex) txtfl = open('websites.txt') webpgsinfile = txtfl.readlines() urls = webpgsinfile htmlfile = urllib.request.urlopen(urls[i]) htmltext = htmlfile.read().decode('utf8') titles = re.findall(pattern,htmltext) if len(titles) > 0: print(titles[0]) i+=1 The

Can't run Pygame script that plays a OGG file compiled through cx_Freeze

不想你离开。 提交于 2019-12-13 01:53:42
问题 When I compile the following script: # play.py import os, re import pygame.mixer pygame.mixer.init(11025) pygame.mixer.music.load('song.ogg') pygame.mixer.music.play(-1) os.system("PAUSE") Using the following setup.py : from cx_Freeze import setup, Executable exe = Executable( script="play.py", ) setup( executables = [exe] ) Through: python setup.py build Executing play.exe gives me the following error: Traceback (most recent call last): File "C:\Python33\lib\site-packages\cx_Freeze