writing

Android NFC Writing doesn't work with 2 activities but works with 1

两盒软妹~` 提交于 2019-12-14 03:27:49
问题 I found a tutorial on how to read and write a NDEF NFC tag via a Toggle Button. I wanted 2 separate buttons and after several days and some help (I am a newbie on Android), I have now managed to do that. I have 2 buttons, related to 2 activities. Clicking on read button will open the read activity and read my tag. Clicking on the write button will open the write activity, pop up the keyboard. I type the text I want to write but when I touch the tag, it sends me back to my main activity where

Python: script to make multiple bash scripts

蓝咒 提交于 2019-12-13 18:20:26
问题 I have a file, called list.txt, which is a list of names of files: input1.txt input2.txt input3.txt I want to build a python script that will make one file for each of these filenames. More precisely, I need it to print some text, incorporate the name of the file and save it to a unique .sh file. My script is as follows: import os os.chdir("/Users/user/Desktop/Folder") with open('list2.txt','r') as f: lines = f.read().split(' ') for l in lines: print "#!/bin/bash\n#BSUB -J",l+".sh","\n#BSUB

Python Multiple file writing question

懵懂的女人 提交于 2019-12-13 14:36:04
问题 I need python to write multiple file names, each file name is different than the last. I have it writing in a for loop. Therefore the data files written from the Python program should look like this: data1.txt, data2.txt, data3.txt. How can I do this in Python 3.2? Obviously, the number is the only thing changing as the file name. 回答1: Alternatively using with for i in range(10): with open('data%i.txt' %i, 'w') as f: f.write('whatever') with takes care of closing the file if something goes

Appending a specific line after having found it in Python [duplicate]

主宰稳场 提交于 2019-12-13 01:59:19
问题 This question already has answers here : Is it possible to modify lines in a file in-place? (5 answers) Inline CSV File Editing with Python (2 answers) Closed 3 years ago . I am writing a function that allows a user to look for content in a specific line (in a file), and replace part of that content in that line, and re-writes it to the file on the same line. def editPlayer(): print "What information would you like to edit?" print "1- Forname" print "2- Surname" print "3- Email address"

Python Element Tree Writing to New File

时间秒杀一切 提交于 2019-12-12 09:00:01
问题 Hi so I've been struggling with this and can't quite figure out why I'm getting errors. Trying to export just some basic XML into a new file, keeps giving me a TypeError. Below is a small sample of the code from xml.etree.ElementTree import ElementTree from xml.etree.ElementTree import Element from xml.etree.ElementTree import SubElement import xml.etree.ElementTree as ET root = Element('QuoteWerksXML') tree = ElementTree(root) ver = SubElement(root, "AppVersionMajor") ver.text = '5.1' tree

Strange problem with reading and writing a plist file

穿精又带淫゛_ 提交于 2019-12-09 20:16:36
问题 I have an application that read info from I plist file. To do it I use this code below: NSData *plistData; NSString *error; NSPropertyListFormat format; id plist; localizedPath = [[NSBundle mainBundle] pathForResource:@"settings" ofType:@"plist"]; plistData = [NSData dataWithContentsOfFile:localizedPath]; plist = [NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error]; if (!plist) { NSLog(@"Error reading

Need help about binary files

穿精又带淫゛_ 提交于 2019-12-08 13:29:22
问题 I'm having trouble creating a code that creates a bin file with multiple lines, each one containing 6 values per line. for example: I'm doing a little project where each line will be a 'password', so my system will load this file and read all passwords from it, when it gets updated and etc. I havent implemented the way to read the file yet because i'm struggling to manipulate the file. This project will be running on linux with GPIO features from Raspberry pi so i'm using Visual Studio for

How can I use file_put_contents() with FILE_APPEND | LOCK_EX safety?

删除回忆录丶 提交于 2019-12-05 15:55:01
问题 This question was migrated from Software Engineering Stack Exchange because it can be answered on Stack Overflow. Migrated 7 years ago . I'm using: file_put_contents("peopleList.txt", $person, FILE_APPEND | LOCK_EX); to write to the end of a file and to make sure no one else (or script) is also writing to the same file at the same time. The PHP manual says it will return a falsy value if unsuccessful. If it cannot obtain a lock on the file, will it fail or keep trying until it can? If it does

Parsing XML Files in .NET

…衆ロ難τιáo~ 提交于 2019-12-05 03:44:35
问题 I'm trying to decide on the best way to load in some configuration settings. Basically, I have an application that several people will log into, and once they've logged in, I want to load all of their settings (for example: colors, font sizes, personal records, etc.) I was thinking of using an XML file to do this because I thought it would be fairly easy to parse in .NET, but it seems to be more difficult that I anticipated. <ProgramSettings> <database file="C:\database.mdb" /> <

Strange problem with reading and writing a plist file

╄→尐↘猪︶ㄣ 提交于 2019-12-04 16:33:33
I have an application that read info from I plist file. To do it I use this code below: NSData *plistData; NSString *error; NSPropertyListFormat format; id plist; localizedPath = [[NSBundle mainBundle] pathForResource:@"settings" ofType:@"plist"]; plistData = [NSData dataWithContentsOfFile:localizedPath]; plist = [NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error]; if (!plist) { NSLog(@"Error reading plist from file '%s', error = '%s'", [localizedPath UTF8String], [error UTF8String]); [error release]; }