text-files

How to delete a .txt file after a certain time? [closed]

不问归期 提交于 2019-12-13 09:48:34
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I have this .txt file that displays information but I want to delete itself after like 5 minutes or so. 回答1: Considering what you are doing, won't using memcached be a better option? You just store your ips as key=value pairs in memcached, with an expiry of 5 minutes. Thus your

How to read .txt file

自闭症网瘾萝莉.ら 提交于 2019-12-13 09:37:00
问题 I'm in need of your help. I have a .txt file and I want to print all the texts using Python 2.7. I've used this code which is shown below. But it is not showing any text except errors. file = open('x.txt' , 'r') print file.read Now, what to do? Thanking you in advance. 来源: https://stackoverflow.com/questions/22440949/how-to-read-txt-file

How to read portions of text from a .txt file in Java?

旧街凉风 提交于 2019-12-13 09:29:05
问题 i was wondering, is there a way to read only parts of a String in a .txt file? Like for example, if "1,5,10,20" is in my .txt file, can i tell Java to save just "1" to a certain int, then save "5" to a different int, and so on? I hope i made it clear enough! Thanks guys! P.S i know how to read a whole line of text in a .txt file in Java using the BufferedReader, just not how to read only certain parts of it. 回答1: You can use Scanner class, which provides a Scanner#nextInt() method to read the

Text File Handling in Visual Basic

对着背影说爱祢 提交于 2019-12-13 09:22:39
问题 I have a text file contains delimited records. 1243;jhhf';982u4k;9u2349;huf8 kij;9238u;98ur23;jfwf;03i24 I need to replace the value of 4th part from every record with the value returned from database or someother source. Any clue ? expecting VB CODE 回答1: Take a look at here( for C# language ); Split string in C# 回答2: You could try this (written in C#): C# release List<string> newLines = new List<string>(); string[] lines = File.ReadAllLines(filename); foreach (string line in lines) { string[

lock text files with passwords [closed]

*爱你&永不变心* 提交于 2019-12-13 09:17:51
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Is there any way to protect the text file. I want to protect my text files to protect with password. So how is it possible that when client wants to open the text file it asks for password and files can be opened in notepad only after entering the right password. By using this can be make our files secure 回答1:

How do I delete a specific nickname and password in a text file?

醉酒当歌 提交于 2019-12-13 09:17:00
问题 I have difficulties on deleting an account in a text file , although it is a school work. Here is my code (long and complicated): create = "" import time import sys while True: print("Type create to create, delete to delete") acc = input("an account or quit to exit Python: ") while acc.lower() == "create": found = False MinName = 5 MinPass = 8 print("Please enter your name.") create = input(">").lower() if len(create) < MinName: print("The name is too short.") print("Please enter your name.")

Make sure matrix row took from text file are same length(python3) [duplicate]

时间秒杀一切 提交于 2019-12-13 09:05:10
问题 This question already has answers here : Making sure length of matrix row is all the same (python3) (2 answers) Closed 5 years ago . so I have this code to input a matrix from a text file: import os path = input('enter file path') there = os.path.exists(path) if there == False: print('Invalid path') menu() matrix = open(path).read() matrix = [item.split() for item in matrix.split('\n')] menu_matrix(matrix) except(ValueError,TypeError): print('Invalid character in text file') My question is

problems with data acquisition from MATLAB

风格不统一 提交于 2019-12-13 08:19:20
问题 I previously asked for help in reading data from a text file generated by a C program (an Exe). Using @second's solution, I solved the problem but yesterday I discovered that the output file is more complex than I had expected. The file output is: V|0|0|0|t|0|1|1|4|11|T4|H13|||||||||||| P|40|0.01|10|1|1|0|40|1|1|1||1|*||0|0|0 *|A1|A1|A7|A16|F|F|F|F|F|F||||||||||||| *|codserv|area|codice|nome|tnom|tmin|tmax|pc|qc|susc||||||| *|||||kV|kV|kV|MW|MVAR|S|||||||||||| N|I|1|N01|N01|132|125.4|138.6|0

Reading data separated by colon per line in Python

ε祈祈猫儿з 提交于 2019-12-13 07:49:48
问题 I'm creating a program that has the user's name and their answers to a guess the number game in a database - like format on Python. I have created a text file where all of the users' data is, in the form name : guess. For instance, Dave:23 Adam:12 Jack:13 Dave:25 Adam:34 Now, I am trying to re - read the file into Python as a tuple, so I decided to use the line of code below (The real answer is 17): dict(line.split(':', 1) for line in open('guesses.txt')) But this will just hand me back an

How to create an input and output file based on user input? [duplicate]

最后都变了- 提交于 2019-12-13 07:48:35
问题 This question already exists : How to combine reading and writing text file in Java. Simple but new to coding [duplicate] Closed 3 years ago . The input file DATA1.txt will contain 7 lines, each a single positive integer describing the amount of candies of each type. The output file OUT1.txt will contain the same number of stars as the number entered. i.e: Input DATA1.txt would show: 12 8 10 5 20 3 7 Output OUT1.txt would show: 12: ************ 8: ******** 10: ********** 5: ***** 20: ********