如何在 python 中完成 JSL 到基數 36 的轉換。
txt = Hex( (Today() - Informat( "01/01/1970", "mm/dd/yyyy" ) - In Hours( 8 )) * 1000 + 600000 + Day( Today() ), base( 36 ) );
a = Today();
b = Informat( "01/01/1970", "mm/dd/yyyy" );
c = In Hours( 8 );
d = Day( Today() );
e = (a - b - c) * 1000 + 600000 + d;
f = Hex( (a - b - c) * 1000 + 600000 + d, base( 36 ) );
我多次詢問ChatGPT,結果與JSL結果不一致。僅向熟悉 JSL 和 python 的專家尋求協助。非常感謝!
自動化和腳本編寫視窗回覆:如何在 python 中完成 JSL 到 36 進位的轉換。您哪個部分有問題?建立要轉換的數字?還是轉換?
回覆:如何在 python 中完成 JSL 到 36 進位的轉換。你對JSL中這個函數的理解嗎
txt = Hex( (Today() - Informat( "01/01/1970", "mm/dd/yyyy" ) - In Hours( 8 )) * 1000 + 600000 + Day( Today() ), base( 36 ) );
如何在 python 中計算出相同的結果
我也不明白 Informat("01/01/1970", "mm/dd/yyyy")。
它計算的是一個Token的結果,如果計算不正確,則無法進行POST下載。
謝謝!
聊天GPT
import datetime
# Step 1: Current time (China's East 8 time zone)
now = datetime.datetime.now()
# Step 2: Date of January 1, 1970
epoch = datetime.datetime(1970, 1, 1)
# Step 3: Calculate the difference in seconds between the current time and January 1, 1970, and subtract 8 hours
time_diff = (now - epoch).total_seconds() - (8 * 3600)
# Step 4: Convert the time difference to milliseconds, add 600,000, and add today's day of the month
milliseconds = time_diff * 1000
e = milliseconds + 600000 + now.day
# Step 5: Convert the result to a base-36 representation
def to_base36(num):
chars = '0123456789abcdefghijklmnopqrstuvwxyz'
base36 = ''
while num > 0:
num, i = divmod(int(num), 36)
base36 = chars[i] + base36
return base36
# Output the base-36 value
result = to_base36(e)
print("Python calculated result:", result)
# Output the current precise timestamp
print("Current timestamp:", now)回覆:如何在 python 中完成 JSL 到 36 進位的轉換。如果你不明白第一部分,你必須從第一部分開始。 In Format 使用指定的格式/模式將字串轉換為 JMP 日期數字

在您的例子中是 2082844800。您可以使用 run_jsl 在 Python 中執行 JSL
回覆:如何在 python 中完成 JSL 到 36 進位的轉換。谷歌搜尋:Python base36
給出了以下 base36 轉換,包括使用 numpy 的 2 行解決方案。
https://stackoverflow.com/questions/1181919/python-base-36-encoding
Python 和 base36 的眾多搜尋結果之一。
另請注意,Python 的紀元日期是1970 年1 月1 日。 如果您取得JMP 的原始日期值,則紀元日期是1904 年1 月1 日。考慮了閏年。
回覆:如何在 python 中完成 JSL 到 36 進位的轉換。python中的這個JSL是如何傳遞給python的?
我將瀏覽一下貼板
謝謝!

回覆:如何在 python 中完成 JSL 到 36 進位的轉換。在 JMP 中,無需使用剪貼簿在 jmp 和 python 之間移動資訊(建議您閱讀https://www.jmp.com/support/help/en/18.0/#page/jmp/python.shtml# )。
import jmp
txt = "initial";
print(txt);
jmp.run_jsl("""
txt = "hello world";
Python Send(txt);
""")
print(txt);

回覆:如何在 python 中完成 JSL 到 36 進位的轉換。我不

回覆:如何在 python 中完成 JSL 到 36 進位的轉換。您忽略的根本問題是 JSL 環境和 Python 環境具有不同的變數範圍。在 JSL 中,當 Names Default To Here(0) 時,名稱會進入全域命名空間;或未指定。當名稱預設為 Here(1) 時,它們位於「here」命名空間中;或者,如果您選擇透過 JSL 建立另一個命名空間,則它們位於特定的命名空間內。進一步特殊的事情,如:age,如果它們是當前資料表的列引用,則會檢查它們。這是邊界的 JSL 一側。在 Python 方面,在 Python 中建立的變數最終會出現在適當範圍的 Python 字典中。在腳本主體的 globals() 字典中。每個模組、函數…都有自己的本地字典。 Python 和 JSL 不會自動相互共享變數。這需要您執行一個操作,將 JSL 變數「傳送」到 Python 環境或將 Python 值「取得」回 JSL 環境。為此,Python Send( v ) 取得 JSL 值 v 並使用 v 值的副本建立一個名為 v 的 Python 變數。但大多數價值觀都是複製品。 jV = Python Get( pV ) ;在Python環境中尋找pV變數並將值複製到JSL變數jV中。
正如@jthi所提到的,有大量 JMP 文件討論了此功能。從 JMP 14 開始,send() / get() 功能一直是 Python 整合的基礎。從說明選單中找到的腳本索引是 JSL 和 Python 內建的 JMP 文件。在腳本索引中,「所有類別」顯示所有內容,旁邊有一個搜尋欄位。 Python 搜尋將快速顯示所有 JSL Python 功能以及描述和可運行範例。如果您選擇「Python」類別,它會進行過濾以顯示 Python 環境支援的所有新 JMP 18+ 功能。您可以在此處找到顯示整合的 JMP 18+ Python 端功能的說明和可運行範例。最後,在 Python 環境中,使用了文件字串,因此您可以使用 Python 的內建幫助功能。例如幫助( jmp.DataTable )



正如您所發現的,Python 套件的靈活性可讓您建立自己的資料傳遞方式。花時間研究我們提供的文件和範例。嘗試使用它們並了解它們的功能,將有助於弄清楚如何最好地利用 JMP 的 Python 整合。
順便說一句,只有當您知道程式碼應該如何運作時,使用 Chat GPT 或其他 AI 工具編寫程式碼才真正有用。就像信任網站文章一樣,您需要足夠了解事物的工作原理(Python、JSL...),才能了解您獲得的程式碼是否準確、幾乎可以工作、概念是否正確,或者只是完整虛假資訊。最後,由於 JMP 18 的新穎性,目前 JMP 18+ Python 整合的 AI 知識可能比 JMP 14-17 上的資訊少很多。 SAMPLE_SCRIPTS 目錄。
回覆:如何在 python 中完成 JSL 到 36 進位的轉換。感謝 保羅!

回覆:如何在 python 中完成 JSL 到 36 進位的轉換。感謝專家!
好的

回覆:如何在 python 中完成 JSL 到 36 進位的轉換。我有兩個問題想請教專家:
1.如何在python中連接兩個JMP表?
2.下面的python如何修改為python asyncio非同步執行形式?
感謝專家!
import jmputils
import jmp
from datetime import datetime, timedelta
today = datetime.today()
dates = []
for i in range(200):
dates.append((today - timedelta(days=i)).strftime('%Y%m%d'))
j = 0
for date in dates:
#print(date)
j += 1
jmp.run_jsl('''
b=Python Get(date);
d1=New Table("o",Add Rows(1),New Column("date",Set Values({b})));
Python Send(d1)
''')
#print(d1)
jmp.run_jsl('''
j=Python Get(j);
//b=Python Get(d1);
if(j==1,d2=d1;d2<<SETNAME></SETNAME><SPAN class="">我仍然沒有答案。</SPAN><SPAN class="">期待專家幫忙。</SPAN>
回覆:如何在 python 中完成 JSL 到 36 進位的轉換。問了幾次ChatGPT,python的asyncio框架是這樣寫的
但執行總是不成功。
向您所在社區的專家尋求協助。
謝謝!
import asyncio
import concurrent.futures
import jmp
# Define a global variable kk
kk = 1
# Create an asynchronous function to run the JSL script
async def run_jsl_script():
global kk
loop = asyncio.get_event_loop()
# Simplified JSL script
jsl_script = f'''
Print("Value of kk: {kk}");
b = Python Get({kk});
Print("Value of b: ", b);
d1 = New Table("o", Add Rows(1), New Column("date", Set Values({{b}})));
if (b == 1,
d2 = d1;
d2 << Set Name("Name 2");
Print("Table d1 copied to d2 with new name.");
,
current data table(d2);
d2 << Concatenate(Data Table(d1), Append to first table);
Close(d1, nosave);
);
Python Send(d1);
'''
# Print the JSL script content for debugging
print("JSL script to be executed:")
print(jsl_script)
try:
# Use a thread pool to run the synchronous JSL script
with concurrent.futures.ThreadPoolExecutor() as pool:
# Call jmp.run_jsl function
await loop.run_in_executor(pool, lambda: jmp.run_jsl(jsl_script))
except Exception as e:
print(f"Error occurred: {e}")
# Update the kk variable
kk += 1
print(f"Current value of kk: {kk}")
# Main asynchronous function
async def main():
# Example of running the JSL script multiple times
for _ in range(3): # For example, run three times
await run_jsl_script()
print("All JSL scripts executed.")
# Run the main function
if __name__ == "__main__":
asyncio.run(main())