text-files

Python Login and Register System using text files

僤鯓⒐⒋嵵緔 提交于 2021-01-29 15:20:48
问题 Hey I am trying to create a system using text files where a user can sign up and log in. All the data will be stored in plain text in a text file called User_Data.txt. My code works but I would like to know if there is anything I missed or If I could improve it in any way. Sorry for the Bad code Formatting in advance. def choices(): print("Please choose what you would like to do.") choice = int(input("For Sigining Up Type 1 and For Signing in Type 2: ")) if choice == 1: return getdetails()

Unobvious Delphi syntax error

点点圈 提交于 2021-01-29 11:50:39
问题 I have a problem with some simple code I simply cannot resolve. I'm using Delphi 5 with all updates applied. I have this code block: procedure TForm1.LoadBtnClick(Sender: TObject); var s1, s2, s3 : Textfile; sa, sb, RString, SQLString : string; begin with sourcequery do begin Close; SQL.Clear; SQL.Add('delete * from source'); ExecSQL; Close; AssignFile(S2, 'c:\delphi programs\events\source1.txt'); AssignFile(S1, 'c:\delphi programs\events\source2.txt'); Reset(s2); Reset(s1); while not eof(s1)

Print To Zebra Printer TLP 3842

梦想的初衷 提交于 2021-01-29 11:12:20
问题 How can I print to Zebra Printer TLP 3842 using EPL Programming? The printer doesn't support Zebra Printer Language (ZPL) and I am using PrintDocument(). I been on this problem for two weeks and can't figure it out. This what I have so far in my code, that actually runs the printer: private System.ComponentModel.Container Components; private System.Windows.Forms.Button PrintButton; private Font PrintFont; private StreamReader StreamToPrint; private void PrintButton_Click(Object Sender,

Python discord.py ways to split output to bypass 2000 character limit

你说的曾经没有我的故事 提交于 2021-01-29 05:06:20
问题 I am attempting to output the contents of a text file to a discord channel via Discord. The issue I have is that there is a 2000 character limit. I have been able to bypass this by using the code below async def on_message(message): id = client.get_guild(73194604108722****) channels = ["football"] if str(message.channel) in channels: if message.content.find("!english") != -1: with open('/home/brendan/Desktop/englishfootball.txt', 'r') as file: await message.channel.send(file.read(2000).strip(

Parsing Text file and placing contents into an Array Powershell

余生颓废 提交于 2021-01-28 14:11:24
问题 I am looking for a way to parse a text file and place the results into an array in powershell. I know select-string -path -pattern will get all strings that match a pattern. But what if I already have a structured textfile, perhaps pipe delimminated, with new entries on each line. Like so: prodServ1a prodServ1b prodServ1c C:\dir\serverFile.txt How can I place each of those servers into an array in powershell that I can loop through? 回答1: You say 'pipe delimited, like so' but your example isn

Python: writing large array of arrays to text file

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-28 05:45:17
问题 I'm new to Python and I have a solution for this but it seems slow and silly, so I wondered if there is a better way? Say I have a matrix defined like this: mat = [['hello']*4 for x in xrange(3)] I am using this function to write it to file: def writeMat(mat, outfile): with open(outfile, "w") as f: for item in mat: f.writelines(str(item).replace('[','').replace(',','').replace('\'','').replace(']','\n')) writeMat(mat, "temp.txt") which gives a text file that looks like: hello hello hello

Count lines in ASCII file using C

丶灬走出姿态 提交于 2021-01-27 16:06:02
问题 I would like to count the number of lines in an ASCII text file. I thought the best way to do this would be by counting the newlines in the file: for (int c = fgetc(fp); c != EOF; c = fgetc(fp)) { /* Count word line endings. */ if (c == '\n') ++lines; } However, I'm not sure if this would account for the last line on all both MS Windows and Linux. That is if my text file finishes as below, without an explicit newline, is there one encoded there anyway or should I add an extra ++lines; after

Count lines in ASCII file using C

一笑奈何 提交于 2021-01-27 15:53:25
问题 I would like to count the number of lines in an ASCII text file. I thought the best way to do this would be by counting the newlines in the file: for (int c = fgetc(fp); c != EOF; c = fgetc(fp)) { /* Count word line endings. */ if (c == '\n') ++lines; } However, I'm not sure if this would account for the last line on all both MS Windows and Linux. That is if my text file finishes as below, without an explicit newline, is there one encoded there anyway or should I add an extra ++lines; after

Python: replacing multiple words in a text file from a dictionary

馋奶兔 提交于 2021-01-27 14:40:25
问题 I am having trouble figuring out where I'm going wrong. So I need to randomly replace words and re-write them to the text file, until it no longer makes sense to anyone else. I chose some words just to test it, and have written the following code which is not currently working: # A program to read a file and replace words until it is no longer understandable word_replacement = {'Python':'Silly Snake', 'programming':'snake charming', 'system':'table', 'systems':'tables', 'language':'spell',

Changing content in Embedded Resources file

谁都会走 提交于 2021-01-08 02:40:28
问题 I want to change the content of a file loaded as a Stream from an embedded resource. The following code gets the file: Stream theFile = Assembly.GetExecutingAssembly().GetManifestResourceStream("_3LinksFourmTool.Resources.fourmlinks.txt"); I created a method that takes a string of text that is present in the Stream provided. The string is rewritten to the Stream with the new content. public static void WriteNewTextToFile(string text, Stream theFile) { string fileText = GetAllTextFromFile