-
Notifications
You must be signed in to change notification settings - Fork 72
lesson_09 #673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
lesson_09 #673
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| def main(): | ||
| text = input() | ||
| print(1 + (text.count(' '))) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| def main(): | ||
| a, b = [x for x in input().split()] | ||
| print(' '.join([b, a])) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W292 no newline at end of file |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| words_to_find = ['ADJECTIVE', 'NOUN', 'VERB', 'NOUN2'] | ||
|
|
||
| filename = input("Enter a filename: ") | ||
| text_file = open(filename, "r") | ||
| content = text_file.read() | ||
| text_file.close() | ||
|
|
||
| for word in words_to_find: | ||
| content = content.replace(word, input("Enter an " + word.lower() + ': '), | ||
| 1) | ||
| write_filename = input("Enter a filename for writing the data: ") | ||
| write_filename = open(write_filename, 'w') | ||
| write_filename.write(content) | ||
| write_filename.close() | ||
|
|
||
| print(content) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W292 no newline at end of file |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import os, re | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E401 multiple imports on one line
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please fix this |
||
|
|
||
|
|
||
| def regex_search(reg): | ||
| regex = re.compile(reg) | ||
| files_list = os.listdir('.') | ||
|
|
||
| for file in files_list: | ||
| if file.endswith('.txt'): | ||
| with open(file) as textfile: | ||
| for line in textfile: | ||
| if regex.match(line): | ||
| print("Regex found " + line) | ||
|
|
||
|
|
||
| regex = input("Enter a regex: ") | ||
| regex_search(regex) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W292 no newline at end of file |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #! python3 | ||
| # mcb.pyw - Saves and loads pieces of text to the clipboard. | ||
| # Usage: py.exe mcb.pyw save <keyword> - Saves clipboard to keyword. | ||
| # py.exe mcb.pyw delete <keyword> - Deletes keyword from clipboard | ||
| # py.exe mcb.pyw <keyword> - Loads keyword to clipboard. | ||
| # py.exe mcb.pyw list - Loads all keywords to clipboard. | ||
|
|
||
| import shelve, pyperclip, sys | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E401 multiple imports on one line |
||
|
|
||
| mcbShelf = shelve.open('mcb') | ||
|
|
||
|
|
||
| # save clipboard content. | ||
| if len(sys.argv) == 3 and sys.argv[1].lower() == 'save': | ||
| mcbShelf[sys.argv[2]] = pyperclip.paste() | ||
| elif len(sys.argv) == 3 and sys.argv[1].lower() == 'delete': | ||
| del mcbShelf[sys.argv[2]] | ||
| elif len(sys.argv) == 2: | ||
| # list keywords and load content. | ||
| if sys.argv[1].lower() == 'list': | ||
| pyperclip.copy(str(list(mcbShelf.keys()))) | ||
| if sys.argv[1].lower() == 'delete': | ||
| for key in mcbShelf.keys(): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E111 indentation is not a multiple of four |
||
| del mcbShelf[key] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E111 indentation is not a multiple of four |
||
|
|
||
| elif sys.argv[1] in mcbShelf: | ||
| pyperclip.copy(mcbShelf[sys.argv[1]]) | ||
|
|
||
| mcbShelf.close() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. W292 no newline at end of file |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #! python3 | ||
| # mcb.pyw - Saves and loads pieces of text to the clipboard. | ||
| # Usage: py.exe mcb.pyw save <keyword> - Saves clipboard to keyword. | ||
| # py.exe mcb.pyw delete <keyword> - Deletes keyword from clipboard | ||
| # py.exe mcb.pyw <keyword> - Loads keyword to clipboard. | ||
| # py.exe mcb.pyw list - Loads all keywords to clipboard. | ||
|
|
||
| import shelve, pyperclip, sys | ||
|
|
||
| mcbShelf = shelve.open('mcb') | ||
|
|
||
|
|
||
| # save clipboard content. | ||
| if len(sys.argv) == 3 and sys.argv[1].lower() == 'save': | ||
| mcbShelf[sys.argv[2]] = pyperclip.paste() | ||
| elif len(sys.argv) == 3 and sys.argv[1].lower() == 'delete': | ||
| del mcbShelf[sys.argv[2]] | ||
| elif len(sys.argv) == 2: | ||
| # list keywords and load content. | ||
| if sys.argv[1].lower() == 'list': | ||
| pyperclip.copy(str(list(mcbShelf.keys()))) | ||
| if sys.argv[1].lower() == 'delete': | ||
| for key in mcbShelf.keys(): | ||
| del mcbShelf[key] | ||
|
|
||
| elif sys.argv[1] in mcbShelf: | ||
| pyperclip.copy(mcbShelf[sys.argv[1]]) | ||
|
|
||
| mcbShelf.close() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| 00-242 | ||
| test | ||
| 01-555 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| The funny panda walked to the monkey and then run. A nearby home was unaffected by these events. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN2 was unaffected by these events. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W292 no newline at end of file