This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import getpass | |
############################ | |
#入力・出力ファイルのパス指定 # | |
############################ | |
import_file_path = os.path.join('C:/Users',getpass.getuser(),'インポートしたいファイルパス') | |
export_file_path = os.path.join('C:/Users',getpass.getuser(),'エクスポートしたいファイルパス') | |
############################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val = 5 | |
#----------------------------------------- | |
#------------------ 1 -------------------- | |
#----------------------------------------- | |
if val == 5: | |
print("test1 exe") | |
#結果:test1 exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
text = '<h2 class="test">sample text for python</h2>' | |
#====================================================== | |
#====================== 1 ============================= | |
#====================================================== | |
#【<h2】を検索し出力 | |
result1 = re.search("<h2",text) | |
print(result1.group(0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
text = '111-222-[333]-444-[5555]' | |
#====================================================== | |
#====================== 1 ============================= | |
#====================================================== | |
#[]内に数字が3つある部分を抽出(エラー処理入り) | |
pattern1 = re.compile(r'\[(\d{3})\]') | |
result1 = pattern1.search(text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str1 = "ababcdcd cdbacdba abcdabcd" | |
import re | |
str2 = re.sub("a","1",str1) | |
print(str2) | |
#1b1bcdcd cdb1cdb1 1bcd1bcd | |
print(re.sub("a","1",str1,4)) | |
#1b1bcdcd cdb1cdb1 abcdabcd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str1 = "abcd abcd abcd" | |
str2 = str1.translate(str1.maketrans({"a": "1", "c": "2"})) | |
print(str2) | |
#1b2d 1b2d 1b2d | |
print(str1.translate(str1.maketrans({"b": "x", "d": None}))) | |
#axc axc axc | |
print(str1.translate(str1.maketrans({"ab": "xy"}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str1 = "abcd abcd abcd" | |
str2 = str1.replace("ab","1") | |
print(str2) | |
#1cd 1cd 1cd | |
print(str1.replace("ab","x",2)) | |
#xcd xcd abcd | |
print(str1.replace("a","")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sample_Var = 0 | |
def Process1(): | |
Sample_Var = 1 | |
def Process2(): | |
global Sample_Var | |
Sample_Var = 1 | |
def Process3(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from PIL import Image | |
import getpass | |
import glob | |
import_file = os.path.join('C:/Users',getpass.getuser(),'入力ファイル名') | |
export_file = os.path.join('C:/Users',getpass.getuser(),'入力ファイル名') | |
#リサイズ後の横幅 | |
RESIZE_X = 1280 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PySimpleGUI as sg | |
layout = [ [ sg.Text("ファイル選択"),sg.InputText(),sg.FileBrowse() ] , | |
[sg.Text("文字入力") ,sg.InputText("ここに文字入力",key ="-TEXT-")], | |
[sg.Checkbox("チェックボックス",key="CHECK-BOX-")], | |
[sg.Button("ボタン", key="-SAMPLE-BUTTON-")] , | |
[sg.Listbox(["Sample A","Sample B","Sample C"],size=(50,5))], | |
[sg.Combo(["Sample D","Sample E","Sample F"])], | |
[sg.ProgressBar(1000,orientation="h",size=(20,20),key="progbar")], | |
] |