Python Code For Free: share phần mềm nho nhỏ liên quan đến xử lí tệp

Chào mọi người hai ngày hôm qua mình đã được các bạn trên diễn đàn giúp đỡ rất nhiều trong lúc mình lập trình một phần mềm nho nhỏ liên quan đến xử lí tệp.
Nên mình nghĩ có lẽ để làm ra được chương trình này mình không thể làm được nếu không có sự giúp đỡ của một số bạn.

Dưới đây là code của mình và nếu các bạn thích thì có thể sửa đổi hay phát triển thêm thoải mái mình nghĩ nó sẽ có ích cho các bạn cũng gặp các vấn đề tương tự như của mình như EOF hay cách sử dụng list hay dict thì trong phần mềm này mình có combine hết tất cả vào rồi.
:grin::grin::grin::smile::smile::smile:

mã nguồn nên up lên github sẽ dễ quản lý và mọi người contribute cũng dễ bạn

Bạn có thể chỉ mình không
Mình thấy mấy bạn up được code lên daynhauhoc mà mình không làm dc

""" 
	This program is use for storing some personal information about all the people I have met before.
	Or maybe it can contain information about some events relative to them 
	This program is built for studying how to code 
	So it have to be very secret 
"""
import sys
from sys import argv

script, information_file = argv

##################################################################
##################################################################
"""This Is The Beginning Of List Defination"""
name = []
age = []
job = []
phone = []
email = []
list_info = []
"""End Of List Defination"""
##################################################################
##################################################################

##################################################################################################################
"""OBJECT ORIENTED PROGRAMMING"""
class Information():
	def __init__(self, name, age, job, phone, email):
		self.name = name
		self.age = age
		self.job = job
		self.phone = phone
		self.email = email
"""END OF OBJECT ORIENTED PROGRAMMING"""

###################################################################################################################
"""PYTHON DEFINE"""
def All(counter):
	print "DO YOU WANT TO SHOW ALL INFORMATION ABOUT THESE OBJECTS ?"
	CHOICE = raw_input(">>> ")
	if CHOICE == "No":
		Printing_Information(counter)
	elif CHOICE == "Yes":
		print ""
		for i in range(counter):
			print "*" * 70
			print "Name Of Object Is: ", list_info[i].name
			print "Age Of Object Is: ", list_info[i].age
			print "Object's Job Is: ", list_info[i].job
			print "Object's Phone Number Is: ", list_info[i].phone
			print "Object's Email Is: ", list_info[i].email
			print "*" * 70
			print ""
		print ""
		print "IT IS DONE !"
		print "PRESS ENTER TO EXIT."
		raw_input()
		sys.exit(0)

def Printing_Information(counter):
	print ""
	print "LIST OF OBJECT IS BELOW."
	for i in range(counter):
		print "OBJECT %d IS: " % (i), list_info[i].name
	print "WHICH OBJECT WOULD YOU LIKE TO CHOOSE ?"
	CHOICE = int(raw_input(">>> "))
	for i in range(counter):
		if CHOICE == i:
			print ""
			print "*" * 70
			print "Name Of Object Is: ", list_info[i].name
			print "Age Of Object Is: ", list_info[i].age
			print "Object's Job Is: ", list_info[i].job
			print "Object's Phone Number Is: ", list_info[i].phone
			print "Object's Email Is: ", list_info[i].email
			print "*" * 70
			Checking()

def Checking():
	print ""
	print "DO YOU WANT TO CONTINUE ? \n"
	CHOICE = raw_input(">>> ")
	if CHOICE == "No":
		print "SYSTEM IS LOGGING OUT."
		raw_input()
		sys.exit(0)
	elif CHOICE == "Yes":
		Printing_Information(counter)
	else:
		print "WRONG INPUT PLEASE TRY AGAIN !!!"
		Checking()

def Upgrade(information_file):
	target = open(information_file, 'a')

	#################################
	print ""
	print "*" * 30
	print "NAME OF OBJECT: "
	Name = raw_input(">>> ")
	print "AGE OF OBJECT: "
	Age = raw_input(">>> ")
	print "OBJECT'S JOB: "
	Job = raw_input(">>> ")
	print "OBJECT'S PHONE NUMBER: "
	Phone_number = raw_input(">>> ")
	print "OBJECT'S EMAIL: "
	Email = raw_input(">>> ")
	print "*" * 30
	print ""
	#################################

	target.write(Name)
	target.write("\n")
	target.write(Age)
	target.write("\n")
	target.write(Job)
	target.write("\n")
	target.write(Phone_number)
	target.write("\n")
	target.write(Email)
	target.write("\n")

	target.close()
	

def Delete(information_file):
	print "DO YOU WANT TO DELETE THIS ???"
	Choice = raw_input(">>> ")
	if Choice == "Yes":
		target = open(information_file, 'w')
		target.truncate()
	elif Choice == "No":
		pass
	else:
		print "PLEASE CHECK AGAIN !"
		print ""
		Delete(information_file)

"""END OF PYTHON DEFINE"""
####################################################################################################################

####################################################################################################################
####################################################################################################################
"""MAIN CODE"""
print "*" * 70
print "\nTHIS PROGRAM WAS DEVELOPED BY NIGHT FOX \n"
print "ALL DATA IN THIS PROGRAM IS USE FOR STUDYING AND IT IS PERSONAL \n"
print "PLEASE DO NOT OPEN OR CRACK OR USE MY PASSWORD TO OPEN THIS \n"
print "*" * 70

DEFAULT_PASSWORD = "1120"
print "" 
print "ENTER THE PASSWORD TO CONFIRM. \n"
RAW_PASSWORD = raw_input(">>> ")
print ""
print "*" * 70

if RAW_PASSWORD != DEFAULT_PASSWORD:
	print ""
	print "THE PASSWORD IS WRONG."
	print "PRESS ENTER TO EXIT."
	raw_input()
	sys.exit(0)
else:
	print "ENTER PASSWORD SUCCESSFUL."
	print ""

	Delete(information_file)

	print "HOW MANY PERSONS DO YOU WANT TO ADD ?"
	n = int(raw_input('>>> '))
	for i in range(n):
		Upgrade(information_file)
	
	target = open(information_file, 'r')

	counter = 0	
	while True:
		get_info = target.readline()
		name.append(get_info)

		get_info = target.readline()
		age.append(get_info)

		get_info = target.readline()
		job.append(get_info)

		get_info = target.readline()
		phone.append(get_info)

		get_info = target.readline()
		email.append(get_info)

		counter += 1

		if not get_info:
			break
	counter = counter - 1		
	target.close()

	for i in range(counter):
		Person = Information(name[i], age[i], job[i], phone[i], email[i])
		list_info.append(Person)
	
	All(counter)
        
"""END OF MAIN CODE"""
####################################################################################################################
####################################################################################################################

	

		
	



Các bạn đừng quan tâm đến mấy cái comment của mình nha
Mình viết ra lúc đầu cho đẹp thôi chứ mình không có í gì hết hì hì
:grin::grin::grin:

Ý mình là nếu project bạn lớn thì nên dùng github để quản lý và sahre đề mọi người cùn g đóng góp, xem thêm ở đây nhe Github Và Cách Sử Dụng Cơ Bản Github Trên Windows

Còn nếu bạn muốn thảo luận thì post code như trên là được rồi

1 Like

Cám ơn bạn
:grinning:

1 Like
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?