15,181 Topics
| |
How do you make Python set an str from a file? For example, my file would contain these pieces of text: username=Eugene password=eugene How do I get Python to return this? >>> print(username) Eugene >>> print(password) eugene Any help is deeply appreciated. Thanks! | |
Hey guys, I had a quick question. Let me try to explain what I'm trying to do here. I'm a bit new to numpy and I'm writing a parallelized code. It is working fine without the use of NumPy, but I'm trying to learn by getting it to work both … | |
Im brand new at python and am trying to teach myself through a book. Im trying to run a very simple command but I keep on getting a syntax error. If someone could take a look at it and tell me what im doing wrong I would greatly appreciate it. … | |
I have been trying to create a text file and code it in UTF-8. I have managed to do it using codecs However, I am having trouble when I ask the user for input. Any ideas? # -*- coding: cp1252 -*- import codecs fileName = "testing1" textFile = codecs.open(fileName, "wt", … | |
Hello im new in python and have a small project to do . my project is cms detector in python at first its in consol and does not has gui . because of im a newbie in programing i dont know how to begin the project . is there any … | |
Hey, Do any one know how to get only Lang ID from Google chrome site ("view-source:https://www.google.com/chrome?hl=en-GB") using this regex "<option value=""([a-zA-Z]*)"">[�-9; a-zA-Z()]*</option>" ? | |
I am writing a script that solves a Quadratic equation. What I am doing wrong and why? The error I get is: [COLOR="Red"]Traceback (most recent call last): File "/home/matthew/Desktop/QuadraticSolver.py", line 5, in <module> c1 = (b * -1) + math.sqrt(((b*b) - 4*a*c) / 2*a) ValueError: math domain error[/COLOR] Here is … | |
How do you make Python delete a specific line of text from a file? For example, delete_input = input ('> ') file = open('blahblah.$','w') #delete the variable delete_input file.delete(delete_input from file) Any form of help would be appreciated. Thanks! | |
I have a very tough problem- how do you make an icon/character move across a console screen? For example, if I press W, +++++ ++E++ +++++ Then I press D +++++ +++E+ +++++ And I want it to be like the CHOICE command in CMD- Without requiring the user to … | |
Hi, I am trying to create a simple GUI which let user to populate a list box base on a click event in wxpython. Can you please point me into a simple tutorial or example which has a sample? For example I have a list of colors: Red, Green, Blue, … | |
| Is there any way to remove an imported library? `Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32` `Type "copyright", "credits" or "license()" for more information.` `>>> dir()` `['__builtins__', '__doc__', '__name__', '__package__']` (Currently imported packages) `>>> import time` `>>> dir()` `['__builtins__', '__doc__', '__name__', '__package__', 'time']` … |
Hi, I'm a newbie to Python and trying to write my first FTP script. Here's the code: from ftplib import FTP ftp = FTP("LoginServer.com") ftp.login("LoginID", "Password") # open the file to read it f = open("C:/Users/MyDocs/Documents/Python/test.txt", "r") # Open directory ftp.cwd("/") # save file ftp.storbinary("STOR test.txt", f) ftp.quit() f.close() I'm … | |
im following along in this nifty little book and one of the coding examples just sparked my interest. data = open('some_file.txt') for each_line in data: print(each_line) How does python know what i want it to do without really telling it? i figured i would have to tell it how i … | |
Hi guys. So, I'm trying to read data from a database and displaying in a GtkTreeview. I used glade to design the GUI when i click on the button (view movies) the list of movies should display as a list. def on_btnmovies_clicked(self,widget,data=None): store=self.builder.get_object('listmovies') connect=sqlite.connect('movies.db') db=connect.cursor() db.execute("SELECT * FROM movie") for … | |
Assume that a file containing a series of names ( as strings ) is named names.dat and exists on the computers disk. Design a program that displays the numbers of names that are stored in the file. ( Hint: Open the file and read every string stored on it. Each … | |
I started using Python a few weeks ago, something finally clicked and I started writing tools for my personal use. I started writing something with a GUI using GTK and the code lines started multiplying rapidly, so I thought to myself "Am I commenting my source to death? How many … | |
im trying to write a program that will read a line of text from a file and then print that text into whereever the cursor is in the browser. like into the address bar or something. is the possible with python? how would i go about doing it. i know … | |
Hi, I'm a beginner at python and I'm trying to extract specific columns from a text file, and then use those columns to make a line plot. The files contains the following few lines of data: # Raw SIFs at Crack Propagation Step: 0 # Vertex, X, Y, Z, K_I, … | |
I am currently working on an app to convert documents (specifically Open Document Text, at least for now) to epub format. The problem I'm running into right now is this, I am using etree ElementTree to parse the xml files extracted from the .odt file, right now I'm working on … | |
Hey guys, I'm new to parallel programming, so I was wondering if anyone could help me parallelize a bit of code. It is a code that goes into large h5 files (using h5py) and grabs some data out. After that the data has to be reformatted and printed into another … | |
How do you make Python delete a string or a number (in this case, .0) from a file? Example: #Error Fixing if '.0' in open('ship.$','r'): #Delete the '.0' | |
I am trying to write a python script to open file, read each line, and replace the 18th position of each line with a a user specified character (sysargv[3]) IF AND ONLY IF that 18th position is another user specified character (sysargv[2]). It should then save it as a file … | |
Hi :) i'm kind of new to this site and everytime I read a thread someone else makes i don't understand what anyone is saying.... :sad: well anyways, please help me python pros. I have been on my very first exercise of "Learn Pyhton the Hard Way" since two weeks … | |
Guys check out http://cx6-dev.blogspot.com/ for an awesome game coded in Python. It's new but still fun. HIGHLY RECOMMENDED! PS: You'll need to have Python 3.2 or above to install/play it. | |
Hello, I was seeking help in why my small program/script is not performing the way I would like. Here is the question. Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each … | |
I had been wanting to write an IRC bot with asynchronous IO for a while. My bot responds to pings, but can be extended by defining functions and registering them to get called when the bot receives certain commands. My bot uses the RFC 1459 USER command and parameters, but … | |
As in C++ was some question about speed of simple hard disk based lookup, here is a version of unscramble program completely HD based lookup, which gives all possible candidate words for multiword anagram. Program is not sensitive for case of words but does not ignore special characters like ' … | |
This is a script that was supposed to be very basic, just running a command with my scripts arguments attached. I didn't realize that if user 'cj' opens firefox, when user 'root' does '**firefox -new-tab**' it doesn't work. Firefox will just open a new window, and thats exactly what I … | |
Hi, I've started learning Python and want to find out how easy is creating GUI for a software. I used to use VB6 with Visual Studio and it was all about Drag and Drop items on a form. Do we have such thing or we just have to hand code … | |
I have a code for a game. money_file = open ('money.$','r').read() money_file = str(money_file) money = int(money_file) But everytime I run it, it returns an error: Traceback (most recent call last): File "C:\Users\eeo.j\Desktop\CX6 SDK\CX6 Normal\CX6.py", line 86, in <module> money = int(money_file) ValueError: invalid literal for int() with base 10: … |
The End.