---
# System prepended metadata

title: Python VBA LINUX
tags: [PEGA]

---


作業三上傳表單：
https://forms.gle/U9qNUyQe898SKekr5

```
# python_file
my_str = '''A long time ago in a galaxy far, far away....
STAR WARS
Epi sode IV
A NEW HOPE
It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire.
During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored space station with enough power to destroy an entire planet.
Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her people and restore freedom to the galaxy....'''
# print(my_str)
path = 'output.txt'
f = open(path, 'w')
f.writelines(my_str)
f.close()
infile = open('output.txt')
lines = infile.read().split("\n")
print(lines)
line_count = len(lines)
word_count = 0
char_count = 0
for line in lines:
    words = line.split()
    print(words)
    word_count += len(words)
    char_count += len(line)
print("File has {0} lines, {1} words, {2} characters".format(
line_count, word_count, char_count))




# my_str = '''A long time ago in a galaxy far, far away....
# STAR WARS
# Episode IV
# A NEW HOPE
# It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire.
# During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored space station with enough power to destroy an entire planet.
# Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her people and restore freedom to the galaxy....'''
# my_str1=my_str.replace('\n',' ')
# space = my_str1.count(' ')+1
# print(my_str1)
# print('共有'+str(space)+'個字')



# name = input("請輸入name: ")
# age = input("請輸入age: ")
# age2 = 60 - int(age)
# print(name + "你還有"+ str(age2) +"幾年退休" )

# def fact(n):
#     """回傳參數 n 的階乘"""
#     r = 1
#     while n > 0:
#         r = r * n
#         n = n - 1
#     return r
# print(fact(4))

```


作業二上傳表單：
https://forms.gle/CNjoy7qwWRjbHDAAA

作業一上傳表單：
https://forms.gle/oe8kh2NpJb6HfsgXA

YZU 上課過程錄影撥放清單：
https://www.youtube.com/playlist?list=PLiMSRllbSoU2KlVU51v48ukMoPQ-cgglw

[py mysql](https://hiskio.com/account/courses)

# 桃園勞工學苑
https://academy-labor.tycg.gov.tw/www/index.aspx?openExternalBrowser=1

# 產投-課程查詢
https://ojt.wda.gov.tw/ClassSearch
kurt.660220@gmail.com / anna1002
liueric650601@gmail.com / anna1002


# Python VBA LINUX
:::success
epic pen 
https://github.com/ kurt.660220@gmail.com anna!002
:::

# Python與OpenCV AI Lin
:::success
Python與OpenCV AI視覺應用班
6-15五 6-23五 6-25日 7-21五
:::



:::spoiler LINE-Py OpenCV AI Line
## LINE-Python OpenCV AI 
Python與OpenCV AI視覺應用班
2023-05-Python與OpenCV AI 視覺應用週五日班
:::

bit.ly/3Nx8j49

https://code.visualstudio.com/download

https://filezilla-project.org/download.php

https://webdesigner.withgoogle.com/

:::spoiler GOOGLE-Python OpenCV AI
## GOOGLE-Python OpenCV AI
中原 張
py20230520@gmail.com anna1002
0936705728
[GoogleDrive](https://drive.google.com/drive/folders/19a6xlock1UISwxo1-6h1a1G7i8Xu4u2n?usp=share_link
)

![](https://drive.google.com/file/d/1PrpO2VLO3nKKFG9r7EwaezkGxPuCoTOj/view?usp=share_link)
:::

:::spoiler 20230528-紹子卿-找出質數
![找出質數](https://hackmd.io/_uploads/rkgub4xL3.png)
:::

:::spoiler 2023-05-26 張正緯 P62-(in List for loop)
## 2023-05-26 張正緯 P62-(in List for loop


``` python
days28 = ["february", "2"]

days30 = [  "4",    "6",       "9",        "11",
          "april", "june", "september", "november"]

days31 = [   "1",      "3",    "5",   "7",     "8",      "10",       "12",
          "january", "march", "may", "july", "august", "october", "december"]


while True:
    month = input("Please enter a month: ")     # "jUnE"
    
##    str1 = month.lower()                        # "june"
##    str1_list = list(str1)                      # ["j", "u", "n", "e"]
##    str1_list[0] = str1[0].upper()              # ["J", "u", "n", "e"]
##    month_final = "".join(str1_list)            # "June"

    if month.lower() in days28:
        print("28/29 days")
    elif month.lower() in days30:
        print("30 days")
    elif month.lower() in days31:
        print("31 days")
    elif month.lower() in ["stop", "done", "finished", "escape", "quit"]:
        print("Thank you")
        break
    else:
        print("Invalid month name")


```python
numbers = [1, 5, 3, 2, 3, 6, 2, 3, 4, 3, 21, 3, 45, 3]


even = 0
odd = 0

for number in numbers:
    if number % 2 == 0:
        even += 1
    else:
        odd += 1

print("Number of even numbers: "  +  str(even) )
print("Number of odd numbers: "   +  str(odd)  )
```


```python
list1 = [1, 2, 3]
list2 = [3, 7, 10]

list3 = []


for index in range( len( list2 ) ):

    list3.append(   list1[index] + list2[index]   )



print(list3)
```

```python

# pg 44 exercise
while True:
    grade = input("Please enter a grade: ")  # "1000x"

    isNumber = True


    for letter in grade:
        if letter not in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "."]:
            isNumber = False

    if isNumber:
        grade = int(grade)

        if grade > 100:
            print("Grade cannot exceed 100")

        elif grade >= 90:
            print("A")
        elif grade >= 80:
            print("B")
        else:
            print("grade cannot be a negative number")
    else:
        print("This is not a valid number")












##words = ['The', 'cat', 'sat', 'on', 'the', 'mat.']
##
##result = ""
##
##
##for word in words:
##    
##    result += word + " "
##
##
##
##print( result )
##    
# pg 44 exercise
while True:
    grade = input("Please enter a grade: ")  # "1000x"

    isNumber = True


    for letter in grade:
        if letter not in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "."]:
            isNumber = False

    if isNumber:
        grade = int(grade)

        if grade > 100:
            print("Grade cannot exceed 100")

        elif grade >= 90:
            print("A")
        elif grade >= 80:
            print("B")
        else:
            print("grade cannot be a negative number")
    else:
        print("This is not a valid number")



##words = ['The', 'cat', 'sat', 'on', 'the', 'mat.']
##
##result = ""
##
##
##for word in words:
##    
##    result += word + " "
##
##
##
##print( result )
##    
```

[ for x in \[listloop\] ](https://colab.research.google.com/drive/19CRctyd3MlQ0WVN7gA_LcICPRwRh8yoI?usp=drive_link)

### [Python 字符串大小写转换](https://www.runoob.com/python3/python3-upper-lower.html)

:::

:::spoiler 2023-05-21 紹子卿
## 2023-05-21 if-else 紹子卿

140.135.178.99:1111


```python
num = 1
running = True

while running:
   password = input("請輸入密碼")

   if password == "test":
       print("密碼正確，歡迎光臨")
       running = False
   elif num >=3:
       print("三次錯誤，程式結束")
       running = False        
   else:
       print("密碼錯誤，重新輸入")
       num +=1

print("謝謝您的使用，再見")
```

```
num1 = int(input("請輸入數值1："))

num2 = int(input("請輸入數值2："))

s = "數值1:"+str(num1)+"比數值2:"+str(num2)
if num1 > num2:
   print(s+"來得大")
elif num1<num2:
   print(s+"來得小")
else:
   print("數值1:"+str(num1)+"和數值2:"+str(num2)+"相等")


choice = input("請選擇(1)加(2)減(3)乘(4)除")

if choice=="1":
   print(num1, "+", num2, "=", num1+num2)
elif choice=="2":
   print(num1, "-", num2, "=", num1-num2)
```
![python-if-else練習-2023-05-21-01](https://hackmd.io/_uploads/SJiI6lwB2.jpg)

:::



:::spoiler 20230519
## 20230519
### TEST
test.py
```

if Human:
    23534
    345435
    3454


if Car:
    if BMW:
        1213
        1231234
        2342
    if Ferrari:
        1231
        124124
        2352
    if Mercedes:
        12421
        234235
        235235


if Plant:
    if Flower:
        12132
        235235
        232
    if Tree:
        1231
        234235
        235235
```
### if_else_passwordLoop.py
```

password = ""

while password != "cisco":
    password = input("Please enter a password: ")

    if password == "cisco":
        print("Successfully Logged In!")
    else:
        print("Incorrect password")
```



### if_elif_cost_exercise6.py if 
```
cost = input("Please enter cost of all items: ")
cost = int(cost)

if cost < 0:
    print("Price cannot be a negative number")
elif cost == 1:
    print("Pay with 1 NT coin")
elif cost <= 5:
    print("Pay with 5 NT coin")
elif cost <= 10:
    print("Pay with 10 NT coin")
elif cost <= 50:
    print("Pay with 50 NT coin")
elif cost <= 100:
    print("Pay with 100 NT bill")
elif cost <= 500:
    print("Pay with 500 NT bill")
elif cost <= 1000:
    print("Pay with 1000 NT coin")
else:
    print("Price cannot exceed 1000 NT")
```

### if_grade_exercise7.py
```


grade = input("Please enter a grade: ") # "86"
grade = float(grade)

if grade >= 0    and   grade <= 100:
    if grade >= 90    and     grade <= 100:
        print("A")
    if grade >= 80    and     grade < 90:
        print("B")
    if grade >= 70    and     grade < 80:
        print("C")
    if grade >= 60    and     grade < 70:
        print("D")
    if grade >= 0    and     grade < 60:
        print("F")
else:
    print("This is not a valid grade")

```

:::

:::spoiler 20230514
## 20230514

car(97)==ord（"a")

[python IDLE 設定](http://140.135.178.99:1111/ )
[python IDLE 設定2](http://localhost:8080/py/20230514/python%20IDLE%20%E8%A8%AD%E5%AE%9A/idlerc%20(1).zip )

### str.index
```
#!/usr/bin/python

str1 = "this is string example....wow!!!";
str2 = "exam";

print str1.index(str2);
print str1.index(str2, 10
```
### str 找字串
print("s" in "student")
print(range(1,10))
print(list(range(1,10)))

### 圖片
![python-if-else練習-2023-05-21-01](https://hackmd.io/_uploads/SJiI6lwB2.jpg)

![python-練習2-2023-05-21-01](https://hackmd.io/_uploads/SJ2kJWwS2.jpg)

![python-練習1-2023-05-21-01](https://hackmd.io/_uploads/BJm0ClDr2.jpg)

```
![練習1] (http://localhost:8080/py/20230514/%E7%B7%B4%E7%BF%921.jpg)

![練習2] (http://localhost:8080/py/20230514/%E7%B7%B4%E7%BF%922.jpg)

![IF ELSE 練習2] (http://localhost:8080/py/20230514/if-else%E7%B7%B4%E7%BF%92.jpg )
```


### 溫度轉換 練習2-2
```
##c = 27.0 #攝氏
##
### 華氏
### c*9 = (f-32)*5
### c*9/5 = f-32
### c*9/5+32 = f 
##f = c*9/5+32
##
##print("攝氏溫度", c , "度等於華氏溫度", f, "度")
##

```

### 錢幣計算 練習2-3
```
price = 137
coin10 = price//10
print("coin10 =",coin10)
coin5 = price%10//5
print("coin5 =",coin5)
coin1 = price%5//1
print("coin1 =",coin1)

```

### 求總和 練習2-8

```
# 梯形公式 ((上底+下底) * 高 ) // 2
num1 = 1
num2 = 100
nums = 100

total = (num1+num2)*nums/2

print(int(total))
```


### if的應用_紅綠燈
```
light = "綠燈"
event = "" 
print("現在是"+light)
if light=="紅燈":
    print("車子必須停下來")
else:
    if event:
        print(event)
        print("車子必須停下來")
        print("行人已走過去")
        
    print("車子可以繼續前進")

    
print("執行其他程式")
print("執行結束")


## 20230512
JFDSAL;
JFDSA'
DFJSAK'
FDSAJ'

```


:::











# [HackMD](https://hackmd.io/?nav=overview)


# Python與ChatGPT整合應用AI人才培育班
:::success
:::
:::spoiler 課程
## 課程
```
一、
課名：Python程式開發與資料處理
上課日期： 112/7/6-112/8/24（週四）
上課時間： 18：30～21：30
上課日期： 112/8/20-112/9/3（週日）
上課時間： 09：30～16：30（中午休息12：30-13：30）
課程內容：
建置Python開發環境、Python程式語言簡介、Python基本語法與結構、變數與資料型態、輸入與輸出格式化、運算式與運算子、容器介紹、串列、字典、元組、集合、切片、條件判斷與迴圈、if條件判斷、for迴圈、while迴圈、生成式Comprehensions函數、def 定義函式、參數、高階函式、匿名函式、遞迴物件導向、封裝（Encapsulation）、繼承（Inheritance）、多型（Polymorphism）檔案管理與JSON、檔案和目錄管理、例外處理、requests 函式庫、JSON、PythonJSON 應用
時數：42（共11次）
師資：張正緯
二、
課名：ChatGPT AI整合應用開發
上課日期：112/7/1-112/8/12（週六）
上課時間：09：30～16：30（中午休息12：30-13：30）
課程內容：
Flask 的基礎知識、MVT（Model、View、Template）模型、建立諮詢表單、
LINE Bot運作流程、用GET及POST方式傳送資料、使用模板、Template語言、資料庫的安裝與使用、目錄架構、資料庫的連結與資料模型的定義、操作資料庫、建立使用資料庫的 CRUD 應用程式、資料表的操作、使用SQL指令操作資料庫、LINE開發者帳號申請、LINE開發者管理控制台、建立LINE Bot圖文選單、LINE Bot API、回應多媒體訊息、ChatGPT介紹和原理、ChatGPT帳號環境設定、OpenAI函示庫介紹和使用、使用OpenAI進行對話、ChatGPT在Line上面進行客服整合
時數：42（共7次）
師資：邵子卿
三、
課名： AI證照與競賽介紹
上課日期： 112/9/10 （週日）
上課時間：09：30～16：30（中午休息12：30-13：30）
課程內容：
(1)AI證照報名流程
(2)AI證照考題分析
(3)AI競賽報名流程
(4)AI競賽團隊分工
(5)專題成果發表演練
時數：6（共1次）
```
:::



# Linux
## manjato
https://youtu.be/uYJytqeNi3E

## docker
https://youtu.be/EAKGwxVSgsI
:::spoiler Youtu.be
## Youtu.be
[玩转Linux命令行 - 初来乍到 - EP1](https://youtu.be/LHYG7eEf8wY)
[linux01](https://youtube.com/playlist?list=PLUDsw5TNnueLvDCGZ7ep1Lq3EdNoNfp1q)
:::
:::spoiler VIM
## VIM
### [Vim 的常用操作](https://bingdoal.github.io/dev-tools/2021/07/vim-usual-operation/)

```
FOR /F  %i in (dd.txt) do set dd=%i

vim --version | grep "clipboard"
sudo apt-get install vim-gnome

:reg
"*yy (win)==>ctrl+c 複製
"*p (win)==>ctrl+v  貼上
"+yy (Linux)
"*

:read !date/t

:Explore

:split :vsplit
:close
ctrl + w w 切換

```
### split & vsplit 分割窗口
https://yianwillis.github.io/vimcdoc/doc/usr_08.html
```
:split :vsplit
:close
ctrl + w w 切換
```
### vim -d 1.txt 2.txt 比較檔案
:::

:::spoiler ==========================
:::


## DMESG
journalctl -k | grep -E "error|fail"

sudo bash StreessCPURAM.bash 2>&1 &

./test.sh > log 2>&1



# PYTHON
:::spoiler  WPS　截圖
## WPS　截圖
ctrl+alt+x
:::

:::spoiler PY  註節 快捷鍵
## PY  註節 快捷鍵
 
```
notepad++
Ctrl + q ，就註解起來了。 
Ctrl + Shift + q ，那就是區塊註解

IDEL
alt+3 Mark
alt+4 UnMark
```
:::

:::spoiler Py Virtualenv & jupyter-notebook
## Py Virtualenv & jupyter-notebook
### [Python 的 Virtualenv](https://medium.com/ai-for-k12/python-%E7%9A%84-virtualenv-%E8%99%9B%E6%93%AC%E7%92%B0%E5%A2%83%E5%AE%89%E8%A3%9D%E8%88%87%E4%BD%BF%E7%94%A8-8645f5884aac)
```
pip3 list
pip3 install virtualenv
cd\
activate
virtualenv env01
cd \env01\Scripts
activate
(env01) C:\env01\Script>

#python3 -m ipykernel install --user --name=python3
#pip install ipykernel
pip install notebook

(env01) C:\env01\Scripts>jupyter-notebook



deactivate


```


:::

:::spoiler GOOGLE-銘傳PY
## 銘傳PY-liueric65060

liueric650601@gmail.com
anna1002
0936705728
:::

:::spoiler GOOGLE-中原PY
## 中原PY-GOOGLE

中原 張
py20230520@gmail.com
0936705728
[GoogleDrive](https://drive.google.com/drive/folders/19a6xlock1UISwxo1-6h1a1G7i8Xu4u2n?usp=share_link
)

![](https://drive.google.com/file/d/1PrpO2VLO3nKKFG9r7EwaezkGxPuCoTOj/view?usp=share_link)

:::


:::spoiler Google Colab
## Google Colablab

:::
# MK
[markdown-mdedito](https://www.mdeditor.tw/)




:::








# ASP.NET Core網站開發與智慧物聯網應用班










# VBA

:::spoiler VBA 元智大學 林柏江老師 講義

## 元智大學 林柏江老師 講義
[元智大學 林柏江老師 講義](https://drive.google.com/drive/folders/15cr1kqsvkLhBxfNSOsY0fZO1gsSzoYIf)
:::

:::spoiler [VBA 影片教學]
## [VBA 影片教學](https://drive.google.com/drive/folders/1Tqdb7bWBcaULO6fFrHj2hxCgvMsWISmE)
:::

:::spoiler VBA MOVIE
https://drive.google.com/file/d/1LI2jAWnktMqJmT0hOtMjPe9oMIs6yPmf/view?usp=share_link
:::


:::spoiler  VBA 正则表达式 RE


## VBA 正则表达式 RE
https://zhuanlan.zhihu.com/p/358630486?utm_id=0

```
1 Function RE(OriText As String, ReRule As String, ReplaceYesOrNo As Boolean)
 2 '''
 3 'OriText：待匹配的字符串
 4 'ReRule：正则表达式
 5 'ReplaceYesOrNo：是否采用替换方法，1表示替换，0表示不替换，默认为不替换
 6 '''
 7 
 8 '创建一个正则表达式实例对象
 9 Set ReObject = CreateObject("vbscript.regexp")
10 
11 With ReObject
12 
13     '是否区分大小写，一般需求是不用区分大小写，因此这里为True
14     .IgnoreCase = True
15     
16     '是否匹配所有，一般需求也都是匹配所有，这里也就默认是True,如果为False表示只匹配第一次出现的
17     .Global = True
18     
19     '匹配时所用到的正则表达式
20     .Pattern = ReRule
21     
22     If ReplaceYesOrNo Then
23         
24         '如果使用替换方法，则将正则表达式匹配到的项替换为空
25         RE = .Replace(OriText, "")
26         
27     Else
28         '否则，返回可迭代对象的第一项
29         RE = .Execute(OriText)(0)
30 
31     End If
32     
33 End With
34 
35 End Function
```




